package com.hwg.shiliupro.exception;


import com.hwg.shiliupro.po.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//全局异常捕获类
@RestControllerAdvice  //声明是处理Rest风格的  异常处理器
public class GlobalExceptionHandlerAdvice {
    /*处理JWT验证没通过*/
    @ExceptionHandler(Exception401.class)
    public R handler401(Exception401 ex){
        //异常处理器拦截到Exception401异常就会通过形参传递进来
        return R.error().code(ex.getCode()).message(ex.getMessage());
    }

    /*处理无权限异常*/
    @ExceptionHandler(Exception403.class)
    public R handler401(Exception403 ex){
        return R.error().code(ex.getCode()).message(ex.getMessage());
    }

}
